'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
    async index() {
        this.ctx.body = 'hi, egg';
    }

    async hello() {
        this.ctx.body = {
            status: 0,
            msg: 'hello world'
        };
    }

    async login() {
        const { app, ctx } = this;
        console.log('login query:', ctx.query);
        console.log('login queries:', ctx.queries);
        const result = await app.mysql.query('select * from tbl_users where phone = ?', ['18525372355']);
        ctx.body = {
            status: 0,
            msg: 'success',
            result
        };
    }

    async create() {
        const { app, ctx, service } = this;
        console.log('create query:', ctx.query);
        console.log('create queries:', ctx.queries);
        console.log('create body:', ctx.request.body);
        ctx.body = {
            success: true,
            data: 'success',
        };
    }
}

module.exports = HomeController;
